package cn.wk.controller;

import cn.wk.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.net.URI;
import java.util.List;

@RestController
@RequestMapping("/consumer/user")
public class ConsumerController {
    @Autowired
    private RestTemplate restTemplate;
    @RequestMapping("/{id}")
    private User getUser(@PathVariable Long id){
        String uri = "http://SPRINGCLOUD-PORVIDER-HYSTRIX";
        //准备一个url
        String url =uri+"/provider/user/"+id;
        return restTemplate.getForObject(url,User.class);
    }
}
